package com.hkw.utils;

/**
 * 分页工具类
 */
public class PagesUtils {
    private int total;  //总条数
    private final int maxrows = 5; //一页最大行数
    private int pages; //总页数
    private int nowPage;  //现在在第几页
    private int beginrow; //开始行数
    //构造方法，按照规律设置一系列属性
    public PagesUtils(int total, int nowPage) {
        this.total = total;
        this.nowPage = nowPage;
        this.pages=(total%maxrows)==0?total/maxrows:total/maxrows+1;
        this.beginrow = (nowPage-1)*this.maxrows;
    }
    public int getNowPage() {
        return nowPage;
    }

    public void setNowPage(int nowPage) {
        this.nowPage = nowPage;
        this.beginrow = (nowPage-1)*this.maxrows;
    }

    public int getMaxrows() {
        return maxrows;
    }

    public int getBeginrow() {
        return beginrow;
    }

    public int getPages() {
        return pages;
    }

    public void setBeginrow(int beginrow) {
        this.beginrow = beginrow;
    }

    public int getTotal() {
        return total;
    }
}
